﻿using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Repositories;
using RedLockNet;

namespace AiQiuQuan.Sport.WebApi.HangfireServices
{
    /// <summary>
    /// 订单自动取消定时任务
    /// </summary>
    [ReccuringJobCron("0 0/5 * * * ?")]
    public partial class AutoCancelOrderHangfireService : IHangfireService
    {
        private readonly IGameOrderRepository _gameOrderRepository;
        private readonly IActivityUserRepository _activityUserRepository;
        private readonly IActivityRepository _activityRepository;
        private readonly IDistributedLockFactory _distributedLockFactory;
        private readonly IUnitOfWorkManager _unitOfWorkManager;
        private readonly ICourseOrderRepository _courseOrderRepository;
        private readonly IGameTeamRepository _gameTeamRepository;
        private readonly IBallUserRepository _ballUserRepository;

        /// <summary>
        /// ctor
        /// </summary>
        public AutoCancelOrderHangfireService(
            IGameOrderRepository gameOrderRepository,
            IActivityUserRepository activityUserRepository,
            IActivityRepository activityRepository,
            IDistributedLockFactory distributedLockFactory,
            IUnitOfWorkManager unitOfWorkManager,
            ICourseOrderRepository courseOrderRepository,
            IGameTeamRepository gameTeamRepository,
            IBallUserRepository ballUserRepository)
        {
            _gameOrderRepository = gameOrderRepository;
            _activityUserRepository = activityUserRepository;
            _activityRepository = activityRepository;
            _distributedLockFactory = distributedLockFactory;
            _unitOfWorkManager = unitOfWorkManager;
            _courseOrderRepository = courseOrderRepository;
            _gameTeamRepository = gameTeamRepository;
            _ballUserRepository = ballUserRepository;
        }

        /// <summary>
        /// 执行
        /// </summary>
        public async Task ExecuteAsync()
        {
            await CourseExecuteAsync();
            await ActivityExecuteAsync();
            await GameExecuteAsync();
            await BallExecuteAsync();
        }
    }
}
